#include <iostream>
#include <string>
#include <iomanip>
#include <ctime>
#include <cstdlib>


using namespace std;

int main()
{
    //女儿的基本信息
    string daughter_name;
    int birth_month=0;
    int birth_date;
    int choice;
    string birth_constellation;
    int value_sum = 0;
    string constellation_table[12][2]={ //星座表
                                        {"山羊座", "水瓶座"},//一月
                                        {"水瓶座", "双鱼座"},//二月
                                        {"双鱼座", "白羊座"},//三月
                                        {"白羊座", "金牛座"},//四月
                                        {"金牛座", "双子座"},//五月
                                        {"双子座", "巨蟹座"},//六月
                                        {"巨蟹座", "狮子座"},//七月
                                        {"狮子座", "处女座"},//八月
                                        {"处女座", "天秤座"},//九月
                                        {"天秤座", "天蝎座"},//十月
                                        {"天蝎座", "射手座"},//十一月
                                        {"射手座", "山羊座"},//十二月
                                      };
    //各月份跨星座日期
    int constellation_date[12]={20, 19, 21, 20, 21, 22, 23, 23, 23, 24, 23, 22};

    // 输入游戏角色信息
    cout<<"女儿的名字是"<<endl;
    cin>>daughter_name;
    cout<<"女儿的生日是几月的"<<endl;
    cin>>birth_month;
    cout<<"女儿的生日是几号的"<<endl;
    cin>>birth_date;
    birth_constellation=constellation_table[birth_month-1][birth_date/constellation_date[birth_month-1]];
    cout<<"女儿的信息："<<endl
        <<"姓名:"<<daughter_name<<endl
        <<"生日："<<birth_month<<"月"<<birth_date<<"日"<<endl
        <<"星座："<<birth_constellation<<endl;

    //星座算法
    //根据星座确定初始属性(体力、智力、魅力、道德、气质）
    int value_daughter_arr[5];
    if(birth_constellation == "白羊座"){
        value_daughter_arr[0] = 80;  value_daughter_arr[1] = 15; value_daughter_arr[2] = 15; value_daughter_arr[3] = 11; value_daughter_arr[4] = 21;
    }
    else if(birth_constellation == "金牛座"){
        value_daughter_arr[0] = 46;  value_daughter_arr[1] = 30; value_daughter_arr[2] = 28; value_daughter_arr[3] = 20; value_daughter_arr[4] = 29;
    }
    else if(birth_constellation== "双子座"){
        value_daughter_arr[0] = 50;  value_daughter_arr[1] = 35; value_daughter_arr[2] = 23; value_daughter_arr[3] = 8;  value_daughter_arr[4] = 20;
    }
    else if(birth_constellation == "巨蟹座"){
        value_daughter_arr[0] = 40;  value_daughter_arr[1] = 31; value_daughter_arr[2] = 33; value_daughter_arr[3] = 17; value_daughter_arr[4] = 33;
    }
    else if(birth_constellation == "狮子座"){
        value_daughter_arr[0] = 85;  value_daughter_arr[1] = 9 ; value_daughter_arr[2] = 11; value_daughter_arr[3] = 20; value_daughter_arr[4] = 37;
    }
    else if(birth_constellation == "处女座"){
        value_daughter_arr[0] = 35;  value_daughter_arr[1] = 28; value_daughter_arr[2] = 36; value_daughter_arr[3] = 18; value_daughter_arr[4] = 40;
    }
    else if(birth_constellation == "天秤座"){
        value_daughter_arr[0] = 42;  value_daughter_arr[1] = 33; value_daughter_arr[2] = 25; value_daughter_arr[3] = 32; value_daughter_arr[4] = 28;
    }
    else if(birth_constellation == "天蝎座"){
        value_daughter_arr[0] = 50;  value_daughter_arr[1] = 25; value_daughter_arr[2] = 40; value_daughter_arr[3] = 18; value_daughter_arr[4] = 17;
    }
    else if(birth_constellation == "射手座"){
        value_daughter_arr[0] = 57;  value_daughter_arr[1] = 31; value_daughter_arr[2] = 15; value_daughter_arr[3] = 19; value_daughter_arr[4] = 20;
    }
    else if(birth_constellation == "山羊座"){
        value_daughter_arr[0] = 56;  value_daughter_arr[1] = 21; value_daughter_arr[2] = 16; value_daughter_arr[3] = 25; value_daughter_arr[4] = 23;
    }
    else if(birth_constellation == "水瓶座"){
        value_daughter_arr[0] = 43;  value_daughter_arr[1] = 43; value_daughter_arr[2] = 20; value_daughter_arr[3] = 23; value_daughter_arr[4] = 17;
    }
    else if(birth_constellation == "双鱼座"){
        value_daughter_arr[0] = 41;  value_daughter_arr[1] = 21; value_daughter_arr[2] = 29; value_daughter_arr[3] = 23; value_daughter_arr[4] = 32;
    }

    //游戏主循环:从1659年6月开始，11岁到18岁的年底
    for(int year = 1659; year <= 1659+7; year++){
        for(int month = (year==1659) ? 6: 1; month <= 12; month++){
            cout << "当前时间：" <<  year << "年" << "-" << month << "月 " ;
            cout << "\n1、查看状态\n2、安排行程\n3、亲子谈话\n" << endl;
            cin >> choice;
            switch(choice){
            case 1://查看状态
                cout << left;
                cout << "嗯，这孩子现在的状况。。。" << endl;
                cout << "姓名：" << daughter_name << endl;
                cout << "生日：" << "1659"<< '-' << birth_month << '-' << birth_date << endl;
                cout << "星座：" << birth_constellation<< endl;
                cout << "年龄：" << year - 1659 + 11 << endl;

                for(int i = 0; i < 5; i++){
                    cout << value_daughter_arr[i] << "：" << setw(4) << value_daughter_arr[i];
                    //设定属性的取值最大值为999
                    int square_number =(int)((value_daughter_arr[i]/99.0) * 10);//实心方块数量
                    for(int j = 0; j < 10; j++){
                        if(j < square_number)
                            cout << "■";
                        else
                            cout << "□";
                    }
                    cout << endl;
                }
                break;
            case 2:{//安排行程
                string month_value[] {"上旬", "中旬", "下旬"};
                int temp1, temp2;
                //一个月只能累计选3次
                for(int i = 0; i < 3; i++){
                    //体力、智力、魅力、道德、气质
                    cout << month << "月" << month_value[i] << "，要做点什么呢？"<< endl;
                    cout << "1、学习武艺\n2、上私塾\n3、学习礼法\n4、出城修行\n" << endl;
                    cout << "请选择：";
                    cin >> choice;
                    srand(time(NULL));
                    switch(choice){
                    case 1://武艺        +体力 +魅力    随机0-5之间
                        value_daughter_arr[0] += temp1 = rand() % 5;
                        value_daughter_arr[2] += temp2 = rand() % 5;
                        cout << "站如松,坐如钟,行如风！" << endl;
                        cout << "勤学苦练之后，" << value_daughter_arr[0] << "增加" << temp1
                             << ", " << value_daughter_arr[2] << "增加" << temp2;
                        break;
                    case 2://学问        +智力 +气质
                        value_daughter_arr[1] += temp1 = rand() % 5;
                        value_daughter_arr[4] += temp2 = rand() % 5;
                        cout << "知之为知之，不知为不知，是知也！" << endl;
                        cout << "认真学习之后，" << value_daughter_arr[1] << "增加" << temp1
                             << ", " << value_daughter_arr[4] << "增加" << temp2;
                        break;
                    case 3://礼法        +道德 +气质
                        value_daughter_arr[3] += temp1 = rand() % 5;
                        value_daughter_arr[4] += temp2 = rand() % 5;
                        cout << "礼尚往来，往而不来非礼也；来而不往亦非礼也！" << endl;
                        cout << "认真诵读之后，" << value_daughter_arr[3] << "增加" << temp1
                             << ", " << value_daughter_arr[4] << "增加" << temp2;
                        break;
                    case 4://出城修行    +体力 +智力
                        value_daughter_arr[0] += temp1 = rand() % 5;
                        value_daughter_arr[4] += temp2 = rand() % 5;
                        cout << "人生由来不满百,安得朝夕事隐忧！" << endl;
                        cout << "外出修行归来，" << value_daughter_arr[0] << "增加" << temp1
                             << ", " << value_daughter_arr[4] << "增加" << temp2;

                        break;
                    }
                }
                break;
            }
            case 3:
            {//亲子谈话
                int temp1;
                cout << "1、打招呼\n2、温柔地说话\n3、严厉地教育\n" << endl;
                cin >> choice;
                if(choice == 1 || choice == 2){
                    cout << "hi，" << daughter_name << "今天吃了吗？...." << endl;
                }else if(choice == 3){
                    cout << "你对女儿" << daughter_name << "进行了一番严厉的教育！" << endl;
                    value_daughter_arr[3] = temp1 = rand() % 16;
                    cout << "道德+" << temp1 << endl;
                }
                for(int i = 0; i < 5; i++){
                    int temp = 10 + rand() % 16;
                    cout << value_daughter_arr[i] << "增加" << temp << endl;
                    value_daughter_arr[i] += temp;
                }
            }
            }
            break;
        }
    }

    //cout << endl;
    //显示游戏结果
    for (int i=0;i<5;i++){
        value_sum+=value_daughter_arr[i];
    }
    if(value_sum >= 2000){
        cout << "经过多年的勤学苦练，" << daughter_name << "终于登上女王大位！" << endl;
    }
    else if(value_sum >= 1800 && value_sum < 2000){
        cout << "王妃" << endl;
    }
    else if(value_sum >= 1600 && value_sum < 1800){
        cout << "女将军" << endl;
    }
    else if(value_sum >= 1200 && value_sum < 1600){
        int maxIndex = 0;
        for(int i = 1; i < 5; i++){
            if(value_daughter_arr[i - 1] < value_daughter_arr[i]){
                maxIndex = i;
                break;//找到最大的属性下标
            }
        }
        //体力、智力、魅力、道德、气质
        //属性总数1200-1600，智力最高，且体力>智力
        if(maxIndex == 0&& value_daughter_arr[0] > value_daughter_arr[1]){
            cout << "皇家学院总裁" << endl;
        }
        else if(maxIndex == 1&& value_daughter_arr[2] > value_daughter_arr[0]){//气质最高，且魅力>体力
            cout << "公主" << endl;
        }
        else if(maxIndex == 2 && value_daughter_arr[4] > value_daughter_arr[2]){//体力最高，且气质>魅力
            cout << "近卫骑士团长" << endl;
        }
        else if(maxIndex == 3 && value_daughter_arr[2] > value_daughter_arr[4]){//道德最高，且魅力>气质
            cout << "高级祭祀" << endl;
        }
        else if(maxIndex == 4 && value_daughter_arr[4] > value_daughter_arr[3]){//魅力最高，且气质>道德
            cout << "国王的宠妃" << endl;
        }

    }
    else{
        string jobArray[] = {"农妇", "魔法师", "修女", "作家", "酒吧女郎"};
        srand(time(NULL));
        int index = rand() % 5;
        cout << jobArray[index] << endl;
    }

    return 0;
}


// FIXME:
//   1. 非常有意思的程序！
//   2. 写完之后，可以考虑把格式调整好，这样看上去比较清楚
//   3. 可以琢磨一下，哪里可以改进，把整个操作都放在一个函数里，这样后续增加新的游戏环节会比较乱
//   4. 考虑如何把这个整个程序，拆分成几个小的函数，例如角色信息输入，初始值设置，游戏过程，结果显示等等
//   5. 如果拆分成几个函数，就要考虑如何把各个变量如何保存，如何设计类的成员变量、成员函数
